﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace BlueLotus7.SSQAnalysisCore
{
    public class BallMartix : ICloneable
    {
        public BallCollection[] Rows
        {
            get;
            set;
        }

        #region Properties

        public BallCollection this[int number]
        {
            get
            {
                return GetRow(number);
            }
        }

        public int Size
        {
            get
            {
                return this.Rows.Length;
            }
        }

        #endregion

        public BallMartix(int count)
        {
            this.Rows = new BallCollection[count];
            for (int i = 0; i < this.Rows.Length; i++)
            {
                this.Rows[i] = new BallCollection(count);
            }
        }

        public BallCollection GetRow(int number)
        {
            if (number > 0 && number <= this.Rows.Length)
            {
                return this.Rows[number - 1];
            }

            return new BallCollection(number);
        }

        public void Clear()
        {
            for (int i = 0; i < this.Rows.Length; i++)
            {
                this.Rows[i].Clear();
            }
        }

        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns> A new object that is a copy of this instance.</returns>
        public object Clone()
        {
            BallMartix clonedObject = new BallMartix(this.Rows.Length);
            Array.Copy(this.Rows, clonedObject.Rows, this.Rows.Length);

            return clonedObject;
        }
    }
}
